package com.seculab.common.dao;

import java.util.List;

import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Repository;

@Repository
public class DefaultDAO extends SqlSessionDaoSupport {

	@Autowired
	private SqlSessionFactory sqlSessionFactory;
	
	@SuppressWarnings("unchecked")
	public List selectList(String statement) throws DataAccessException {
		return (List)getSqlSession().selectList(statement);
	}	
	
	@SuppressWarnings("unchecked")
	public List selectList(String statement, Object parameter) throws DataAccessException {
		return (List)getSqlSession().selectList(statement, parameter);
	}	
	
	@SuppressWarnings("unchecked")
	public int insert(String statement, Object parameter) {
		return getSqlSession().insert(statement, parameter);
	}	
	
	@SuppressWarnings("unchecked")
	public Object select(String statement, Object parameter) {
		return getSqlSession().selectOne(statement, parameter);
	}	
	
	@SuppressWarnings("unchecked")
	public Object update(String statement, Object parameter) {
		return getSqlSession().update(statement, parameter);
	}	
	
	@SuppressWarnings("unchecked")
	public int delete(String statement, Object parameter) {
		return getSqlSession().delete(statement, parameter);
	}	
	
}
